<?php
/**
 * Created by PhpStorm.
 * User: peter
 * Date: 2018/6/19
 * Time: 7:43 PM
 */

namespace app\mall\logic;


use extend\Functions;
use extend\STATUS_CODE;

class Area
{
    /**
     * @purpose 通过pid获取区域信息
     * @param int $pid
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public static function areaByPid(int $pid = 0):array
    {
        $model      = new \app\model\Area();
        $result     = $model
            ->where('pid', $pid)
            ->field('id,pid,area_code,name,short_name')
            ->select();
        return Functions::result(
            STATUS_CODE::SUCCESS,
            $result
        );
    }
}